<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/taglibs.jsp" %>

<c:set var="CURRENT_SEQNO">
	<sec:authentication property='principal.users.seq_no' />
</c:set>

<c:choose>
	<c:when test="${fn:length(_QueryForm.obj) == 0}">
		<div style="width:650px;padding-top:10px;padding-left:20px;font-size: 16px;color: red;font-weight: 600;letter-spacing: 4px;vertical-align: middle; ">
			<img src="${appPath }/resource/image/warning.png" />
			查無筆數，請重新查詢
		</div>
	</c:when>
	<c:otherwise>
		<table style="width:650px;background-color:#ffffff;border:1px solid #D2D9E7;" >	
			<tr class="trHeader">
				<td style="width:05%" align="center">
					<input type="checkbox" onclick="checkedSelected(this);" value="all" id="chkAll"/>
				</td>
				<td style="width:05%" align="center">序號</td>
				<td style="width:10%" align="center">帳號</td>
				<td style="width:25%" align="center">姓名</td>
				<td style="width:25%" align="center">Email</td>
				<td style="width:15%" align="center">角色</td>
				<td style="width:20%" align="center">功能</td>
			</tr>
			
			<c:forEach var="plist" items="${_QueryForm.obj}" varStatus="s">
				<tr class="trContent" id="tr_${plist.seq_no}">
					<td align="center">
						<c:if test="${(CURRENT_SEQNO != plist.seq_no) && (plist.seq_no != 1)}">	
							<input type="checkbox" onclick="checkedSelected(this);" value="${plist.seq_no}" class="chk_sn" />
						</c:if>
					</td>
					<td align="center">${_QueryForm.firstResult + s.count }</td>
					<td align="center">${plist.username}</td>
					<td align="center">
						<span id="dsp_fullname_${plist.seq_no}">
							${plist.fullname}
						</span>
						<span id="mdy_fullname_${plist.seq_no}" style="display:none">
							<input type="text" value="${plist.fullname}" id="fullname_${plist.seq_no}" style="width:140px;" class="bar_2"/>
						</span>
					</td>
					<td style="padding-left:10px;">						
						<span id="dsp_email_${plist.seq_no}">
							${plist.email}
						</span>
						<span id="mdy_email_${plist.seq_no}" style="display:none">
							<input type="text" value="${plist.email}" id="email_${plist.seq_no}" style="width:140px;" class="bar_2"/>
						</span>
					</td>
					<td align="center">
						
						
						<span id="dsp_role_${plist.seq_no}">
							<c:forEach var="role" items="${plist.roleMap}">
								<c:if test="${role.value}" >
									${role.key.description}<br/>
								</c:if>															
							</c:forEach>
						</span>
						
						<span id="mdy_role_${plist.seq_no}" style="display:none">
							<c:forEach var="role" items="${plist.roleMap}">
								${role.key.description}
								<input type="checkbox" value="${role.key.name},${role.key.description}" class="role_${plist.seq_no}" 
									<c:if test="${role.value}" >
										checked="checked"
									</c:if>								
								/>								
								<br/>								
							</c:forEach>
						</span>
					</td>
					<td align="center">			
						
							<span id="mode_default_${plist.seq_no}" style="display:;">
								<a href="javascript:void(0);" onclick="del('${plist.seq_no}');">刪除</a>／
								<a href="javascript:void(0);" onclick="toModify('${plist.seq_no}');">修改</a>
							</span>
							<span id="mode_mdy_${plist.seq_no}" style="display:none;">
								<a href="javascript:void(0);" onclick="modify('${plist.seq_no}');">
									<img src="${appPath }/resource/image/check.png" border="0" title="確認修改" />				
								</a>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<a href="javascript:void(0);" onclick="discardChanges('${plist.seq_no}');">
									<img src="${appPath }/resource/image/error.png" border="0" title="放棄修改" />
								</a>
							</span>
						
					</td>
				</tr>
			</c:forEach>
		</table>
		<div style="width:650px;padding-top:10px;">${_QueryForm.pageInfo}</div>
	</c:otherwise>
</c:choose>


<form:form method="post" modelAttribute="_QueryForm" action="${appPath}/admin/users/select.htm" >
<form:hidden path="qr_str" />
<form:hidden path="nowPage" />
<form:hidden path="firstResult" />
<form:hidden path="rowsPerPage" />
<form:hidden path="totalPages" />
<form:hidden path="totalRows" />
</form:form>

<form method="post" id="UsersForm" >
<input type="hidden" name="seq_no" />
<input type="hidden" name="fullname" />
<input type="hidden" name="email" />
<input type="hidden" name="roleItems" />
</form>
